<?php

//xSystem/index.php

class_exists("xSystemConfig", false) or die("Config Class Not Exist!");

class __example__xSystemConfig{

    static $session_name = "";
    static $db = [
        'host' => '',
        'user' => "",
        'pass' => '',
        'db' => [
            'default' => ''
        ]
    ];
    static $error = [
        "error_reporting" => E_ALL,
        "display_errors" => true
    ];
    static $time_limit = 120;

}

//session & buffer init---------------------------------------------------------
session_name(xSystemConfig::$session_name);
session_start();
ob_start();

//------------------------------------------------------------------------------
chdir(xSystemConfig::$xSystemDirname); // vcvli direktorias xsystemistvis
//require startup files---------------------------------------------------------
require_once './system/system.cls.php';
require_once './system/helper.cls.php';

//require system classes--------------------------------------------------------
require_once './system/constants.php';
require_once './system/sys/fn.php';
require_once './system/sys/db.php';
require_once './system/sys/gui.php';

//registering objects-----------------------------------------------------------
$database = new db();

function db(){
    global $database;
    return $database;
}

//error reporting---------------------------------------------------------------
error_reporting(xSystemConfig::$error['error_reporting']);
ini_set('displey_errors', xSystemConfig::$error['display_errors']);
set_time_limit(xSystemConfig::$time_limit);
//------------------------------------------------------------------------------
helper::timedebug("index");
//------------------------------------------------------------------------------
if(is_array($_REQUEST)){
    $_REQUEST = helper::__esc($_REQUEST);
    define("REQUEST_ESCAPED", true, true);
}

//------------------------------------------------------------------------------
chdir(xSystemConfig::$originalScriptDir); // vabruneb original direktorias
?>